<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="com.sfilyh.util.DBUtil" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	request.setAttribute("nav", 3);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link rel="stylesheet" type="text/css"  href="<%=request.getContextPath()%>/css/cssbase.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/admin.css" />
</head>
<body>
<div class="header"></div>
<div class="content">
	<div class="left">
    	<h3 class="left_menu_title">操作菜单</h3>
        <jsp:include page="/WEB-INF/views/admin/left.jsp" />
    </div>
	<div class="right">
    	<table class="right_table">
        	<thead>
            	<tr>
            		<th style="width:100px;">排序</th>
                	<th style="width:100px;">类型</th>
                    <th style="width:100px;">名称</th>
                    <th></th>
                </tr>
            </thead>
            <tbody>
            
            	<c:forEach var="item" items="${categoryList}">				
				<tr>
					<td style="text-align: center;"><input class="cSort" type="text" style="width:50px;text-align: center;" value="${item.sort}" data-id="${item.id}" data-old="${item.sort}" /></td>
                	<td class="tb_category_type">
                	<c:choose>
                		<c:when test="${item.type == 0}">
                			分类
                		</c:when>
                		<c:when test="${item.type == 2 }">
                			page
                		</c:when>                		
                	</c:choose>                	
                	</td>
                    <td class="tb_category_name">${item.cname}</td>
                    <th>
                    	<a href="<%=request.getContextPath()%>/bz-admin/delCategory?id=${item.id}" onclick="javascript:if(confirm('确定要删除吗？')){return true;}else{return false;}">[删除]</a>
                        <a href="<%=request.getContextPath()%>/bz-admin/addCategory?id=${item.id}">[修改]</a>
                    </th>
                </tr>                
				</c:forEach>
				                       
            </tbody>        	
        </table>
    </div>
</div>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
    	$('.cSort').blur(function(){
    		var id = $(this).data('id');
    		var oldSort = $(this).data('old');
    		var sort = $(this).val();
    		if(sort != oldSort && !isNaN(sort)){
    			$.post('<%=request.getContextPath()%>/bz-admin/updateCsort',{id:id,sort:sort});
    		}
    	});
    });
</script>
</body>
</html>
